<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('strator_departments', function (Blueprint $table) {
            $table->id();

            $table->unsignedInteger('pid')->default(0)->comment('上级部门id，0为顶级部门');
            $table->string('department_name')->unique()->comment('部门名称');
            $table->char('department_code',32)->unique()->nullable()->comment('部门代码');
            $table->string('department_remark')->nullable()->comment('部门简介，备注');
            $table->integer('sort')->default(0)->index()->comment('排序');

            $table->timestamps();
            $table->softDeletes();
        });

        \DB::statement("ALTER TABLE `strator_departments` comment '管理员部门表'");
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('strator_departments');
    }
};
